﻿using PictureSearch.AppCode;
using System.Windows.Media.Imaging;

namespace PictureSearch
{
    public partial class GalleryItem
    {
        public string FileName { get; private set; }

        public GalleryItem(string imageFileName)
        {
            InitializeComponent();

            FileName = imageFileName;

            ImageCommon.GetImageData(imageFileName, (stream) =>
                {
                    this.Dispatcher.BeginInvoke(() =>
                    {
                        var img = new BitmapImage();
                        img.SetSource(stream);
                        stream.Close();

                        image.Source = img;
                    });
                });
        }
    }
}
